package com.example.demo.controller;

import com.example.demo.entity.Student;
import com.example.demo.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
public class StudentController  {

    @Autowired
    StudentService studentService;

    @PostMapping("/student")
    public int save(@RequestBody Student student){
        return studentService.save(student);
    }

    @DeleteMapping("/student/{sId}")
    public int delete(@PathVariable("sId") int sId){
        return studentService.delete(sId);
    }

    @PutMapping("/student")
    public int update(@RequestBody Student student){
        return studentService.update(student);
    }

    @GetMapping("/student")
    public List<Student> select(){
        return studentService.select();
    }


}
